package cn.tedu.boot01.controller;

import cn.tedu.boot01.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class ParamController {
    @RequestMapping("/p1")
    /*@ResponseBody //添加此注解可以通过返回值的方式给客户端响应数据*/
    public String p1(HttpServletRequest request) {
        // 从请求对象request里面得到传递过来的参数
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        return "测试成功!name=" + name + ",age=" + age;
    }

    @RequestMapping("/p2")
//    @ResponseBody
    public String p2(String name, int age) {
        return "测试2成功! name=" + name + ", age=" +age;
    }

    @RequestMapping("/p3")
//    @ResponseBody
    public String p3(Emp emp) {
        // soutp快捷键打桩
        System.out.println("emp = " + emp);
        return emp.toString();
    }
}
